package com.hs.jhzd.repository;

import com.hs.jhzd.entity.Prisoner;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface PrisonerRepository extends JpaRepository<Prisoner, String> {


  List<Prisoner> findByJshAndRybj(String jsh, String rybj);

  List<Prisoner> findByRybj(String rybj);

  Prisoner findByRybh(String rybh);

  // Prisoner findByCardId(String cardId);

  Prisoner findByJshAndCardIdAndRybj(String jsh, String cardId, String rybj);

  Prisoner findByFh(String fh);

  List<Prisoner> findByInPrisonDateAfterOrderByInPrisonDateDesc(Date inPrisonDate);

  List<Prisoner> findByName(String name);

  @Query("SELECT u from Prisoner u where u.rybj='0' and u.outPrisonDate > :lastSynchronizeTime")
  List<Prisoner> getPrinsoner2Delete(@Param("lastSynchronizeTime") Date lastSynchronizeTime);

    List<Prisoner> findByJshAndRybjAndJsbh(String jsh, String rybj, String jshb);
}
